<?php

function tsts_skins_add_settings() {

// Add a form section for the skin theme settings
add_settings_section('tsts_settings_skin', 'tsts Theme Skins', 'tsts_settings_skin_section_text', 'tsts');

// Add skin setting to the skin section
add_settings_field('tsts_setting_skin', 'Available Skins', 'tsts_setting_skin', 'tsts', 'tsts_settings_skin');

}
add_action( 'admin_init', 'tsts_skins_add_settings' );



// Skin Settings Section
function tsts_settings_skin_section_text() {
     $tsts_options = get_option( 'tsts_options' );
     $tsts_skins = tsts_get_valid_skins();
     $imgstyle = 'float:left;margin-right:20px;margin-bottom:20px;border: 1px solid #bbb;-moz-box-shadow: 2px 2px 2px #777;-webkit-box-shadow: 2px 2px 2px #777;box-shadow: 2px 2px 2px #777;';
     foreach ( $tsts_skins as $skin ) {
          if ( $skin['slug'] == $tsts_options['skin'] ) {
               $tsts_current_skin = $skin;
          }
     } ?>
     <p><?php _e( 'There is more than one way to skin a cat.', 'tsts' ); ?></p>
     <img style="<?php echo $imgstyle; ?>" src="<?php echo get_template_directory_uri() . '/lib/tsts_functions/theme-options/images/' . $tsts_options['skin'] . '.png'; ?>" width="150px" height="110px" alt="<?php echo $tsts_options['skin']; ?>" />
     <h4>Current Skin</h4>
     <dl>
          <dt><strong><?php echo $tsts_current_skin['name']; ?></strong></dt>
          <dd><?php echo $tsts_current_skin['description']; ?></dd>
     </dl>
<?php }




// Skin Setting
function tsts_setting_skin() {
     $tsts_options = get_option( 'tsts_options' );
     $tsts_skins = tsts_get_valid_skins();
     $dlstylebase = 'float:left;padding:5px;text-align:center;max-width:160px;';
     $dlstylecurrent = 'border: 1px solid #999;-moz-box-shadow: 2px 2px 2px #777;-webkit-box-shadow: 2px 2px 2px #777;box-shadow: 2px 2px 2px #777;';
     foreach ( $tsts_skins as $skin ) {
          $currentskin = ( $skin['slug'] == $tsts_options['skin'] ? true : false );
          $dlstyle = ( $currentskin ? $dlstylebase . $dlstylecurrent : $dlstylebase ); ?>
          <dl style="<?php echo $dlstyle; ?>">
               <dt><strong><?php echo $skin['name']; ?></strong></dt>
               <dd><img style="border: 1px solid #bbb;" src="<?php echo get_template_directory_uri() . '/lib/tsts_functions/theme-options/images/' . $skin['slug'] . '.png'; ?>" width="150px" height="110px" alt="<?php echo $skin['name']; ?>" /></dd>
               <dd><input type="radio" name="tsts_options[skin]" <?php checked( $currentskin ); ?> value="<?php echo $skin['slug']; ?>" /></dd>
               <dd><small><?php echo $skin['description']; ?></small></dd>
          </dl>
<?php }
}



?>